 @include "lib.awk"
 function testStatistic(y,z,   \
                        m,n,ymu,zmu,tmp1,tmp2,tmp3,s1,s2,i) {
   m= length(y)
   n= length(z)
   ymu= mean(y)
   zmu= mean(z)
   for(i in y) tmp1 += (y[i] - ymu)^2
   for(i in z) tmp2 += (z[i] - zmu)^2
   s1   = tmp1/(m-1)
   s2   = tmp2/(n-1)
   tmp3 = (zmu - ymu)/sqrt(s1/m + s2/n)
   return tmp3
 }
 function bootstrap(y,z,conf,b,                                  \
                    tobs,x,xmu,ymu,zmu,i,yhat,zhat,bigger,asl) {
   b    = b    ?  b   : 1000
   conf = conf ? (100 - conf) / 100 : 0.05
   tobs = testStatistic(y,z)
   concat(y,z,x)
   xmu = mean(x)
   ymu = mean(y)
   zmu = mean(z)
   for(i in y) yhat[i] = y[i] - ymu + xmu
   for(i in z) zhat[i] = z[i] - zmu + xmu
   for(i=1;i<=b;i++) 
     bigger += (bootstrap1(y,yhat,z,zhat) > tobs)
   asl= bigger/b
   return asl < conf
 }
 function bootstrap1(y,yhat,z,zhat,     ystar,zstar,i) {
   for(i in y) ystar[i] = any(yhat)
   for(i in z) zstar[i] = any(zhat)
   return testStatistic(ystar,zstar) 
 }
